<template>
  <el-collapse v-model="activeNames"
               :class="'collapse-defined-box'+type">
    <el-collapse-item :title="title"
                      name="1"
                      v-if="type === 1||type === 2">
      <template slot="title">
        {{title}}
        <span v-if="type===2"
              class="left-title-bg color-span-bg"></span>
      </template>
      <slot></slot>
    </el-collapse-item>
    <el-collapse-item v-else
                      :title="title"
                      name="1"
                      class="warp-content">
      <template slot="title">
        {{title}}
      </template>
      <slot></slot>
    </el-collapse-item>
  </el-collapse>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: '',
      remark: '标题'
    },
    type: {
      type: Number,
      default: 1,
      values: '1，2，3',
      remark: '类型'
    },
    isExpand: {
      type: Boolean,
      default: true,
      values: 'true/false',
      remark: '是否展开，默认true'
    }
  },
  data () {
    return {
      activeNames: this.isExpand ? ['1'] : []
    }
  }
}
</script>

<style lang="scss">
.collapse-defined-box,
.collapse-defined-box1 {
  .el-collapse-item__wrap {
    overflow: visible;
  }
  &.el-collapse,
  .el-collapse-item__wrap,
  .el-collapse-item__header {
    border-bottom: 1px solid transparent;
    border-top: none;
  }
  .el-collapse-item__header {
    height: 30px;
    display: flex !important;
    flex-flow: row-reverse nowrap;
    align-items: center;
    justify-content: flex-end;
    font-size: 14px;
    width: 100%;
    color: #333333 !important;
    white-space: nowrap;
    cursor: pointer;
    &::before {
      content: "";
      border-top: 1px solid #f1f5f8;
      width: calc(100% - 50px);
      margin-left: 10px;
    }
    .el-collapse-item__arrow {
      margin: 0 6px 0 0;
    }
  }
  .el-collapse-item__content {
    padding-bottom: 0;
  }
}

.collapse-defined-box2 {
  .el-collapse-item__wrap {
    overflow: visible;
  }
  &.el-collapse,
  .el-collapse-item__wrap,
  .el-collapse-item__header {
    border-bottom: 1px solid transparent;
    border-top: none;
  }
  .el-collapse-item__header {
    height: 30px;
    display: flex !important;
    flex-flow: row-reverse nowrap;
    align-items: center;
    justify-content: flex-end;
    font-size: 14px;
    width: 100%;
    color: #333333 !important;
    white-space: nowrap;
    cursor: pointer;
    position: relative;

    .el-collapse-item__arrow {
      position: absolute;
      right: 0;
      margin: 0;
    }

    .left-title-bg {
      display: inline-block;
      width: 4px;
      height: 20px;
      margin-right: 6px;
    }
  }
  .el-collapse-item__content {
    padding-bottom: 0;
  }
}
.collapse-defined-box3 {
  &.el-collapse {
    border-bottom: 1px solid transparent;
    border-top: none;
  }
  .el-collapse-item__wrap {
    padding: 10px 10px 0 10px;
    border-bottom: 1px solid transparent;
    border-top: none;
  }
  .el-collapse-item__header {
    padding: 0 10px;
    border-top: none;
    border-bottom: 1px solid #ebeef5;
    border-bottom-color: #ebeef5 !important;
    display: flex;
    flex-flow: row-reverse;
    align-items: center;
    justify-content: flex-end;
    .el-collapse-item__arrow {
      margin: 0 6px 0 0;
    }
  }
  .el-collapse-item__content {
    padding-bottom: 0;
  }
}
</style>